// 定义子组件
import { useState } from 'react'
import store from '../redux';

export default function Child() {
    let [num, setNum] = useState(store.getState().num);
    store.subscribe(() => {
        setNum(store.getState().num)
    })
    return (
        <div>

            <div> Child--{num} </div>

            <button onClick={() => {
                store.dispatch({
                    type: "reduce"
                })

            }}>--</button>
        </div>
    )
}
